s1 = {10, 20}
# 1. 集合是可变类型
# add()
# s1.add(100)
# print(s1) #{100, 10, 20}

# 集合有去重功能，如果追加的数据是集合已有数据，则什么事情都不做
# s1.add(10)
# print(s1) #{10, 20}
"""
Traceback (most recent call last):
  File "D:\program files\JetBrains\PyCharm 2025.1.2\plugins\python-ce\helpers\pydev\pydevd.py", line 1570, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\program files\JetBrains\PyCharm 2025.1.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "E:\文件资料\python-study\Code\04-数据序列\05-集合\hm_02_集合常见操作之增加数据.py", line 11, in <module>
    s1.add([10, 20, 30])  # 报错
    ^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'list'
python-BaseException
"""
# s1.add([10, 20, 30])  # 报错
# print(s1)

# update()： 增加的数据是序列
s1.update([10, 20, 30, 40, 50])
print(s1) #{40, 10, 50, 20, 30}

s1.update(100)  # 报错

"""
Traceback (most recent call last):
  File "D:\program files\JetBrains\PyCharm 2025.1.2\plugins\python-ce\helpers\pydev\pydevd.py", line 1570, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\program files\JetBrains\PyCharm 2025.1.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "E:\文件资料\python-study\Code\04-数据序列\05-集合\hm_02_集合常见操作之增加数据.py", line 30, in <module>
    s1.update(100)  # 报错
    ^^^^^^^^^^^^^^
TypeError: 'int' object is not iterable
"""
print(s1)



